package com.article.service.impl;

import java.util.List;

import com.article.dao.IUserDAO;
import com.article.entity.User;
import com.article.service.IUserService;

@SuppressWarnings("unchecked")
public class UserServiceImpl implements IUserService {
	private IUserDAO userDAOImpl;

	public User checkLogin(String userName, String password) {
		if(userName == null || password == null || "".equals(userName) || "".equals(password)){
			return null;
		}
		//根据用户名查询用户
		List<User> list = userDAOImpl.findByUserName(userName);
		if(list != null && list.size() > 0){
			User user = list.get(0);
			//判断用户密码是否正确
			if(user.getPassword().equals(password)){
				return user;
			}
		}
		return null;
	}

	public void setUserDAOImpl(IUserDAO userDAOImpl) {
		this.userDAOImpl = userDAOImpl;
	}

}
